home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 November
/
EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso
/
earcd
/
util
/
cli
/
0utils.lha
/
0Utils
/
ReadLn.data
< prev
next >
Wrap
Text File
|
1995-08-19
|
2KB
|
86 lines
#ifdef TPLTER
ReadLn = {
SHORT = {{ Read Line[s] from a filehandle }};
DESCRIPTION = {{
ReadLn reads linesfrom a filehandle previosly opened
with the 'Open' command. its purpose is to split the
contents of a certain file in order to be able to
handle it with different other commands, without a need
of using another scripting language (like e.g. ARexx).
ReadLn does no checks on the given filehandle, so
it should be used carefully.
RESULT
the read lines
}};
NOTES = {{
! ReadLn is highly dangerous! Do not Use it, !
! if U do not exactly know what U are doing! !
}};
EXAMPLES = {{
> set fh `Open Sys:S/Shell-startup`
> Readln $fh
alias xcopy "copy clone "
> Close $fh
> Unset fh
}};
HISTORY = {{
21-02-95 b_noll created
21-02-95 b_noll added version/format-prefix/offset
20-03-95 b_noll added args diagnostics
20-03-95 b_noll ReadLn always skipped one line
19-08-95 b_noll created .data file
}};
Template = "FILEHANDLE/N/A,LINES/N/K";
Arguments = {{
BPTR *filehandle;
ULONG *lines;
}};
version = "1.1";
body = {{
if (argv->filehandle && *argv->filehandle) {
UBYTE buffer[MAXLINELEN];
ULONG lines = 1;
/* MISSING: CHECKREGISTER(*argv->filehandle); */
if (argv->lines) lines = *argv->lines;
retval = RETURN_OK;
while ((retval == RETURN_OK) && lines && FGets(*argv->filehandle, buffer, MAXLINELEN)) {
-- lines;
if (PutStr(buffer)) {
retval = RETURN_ERROR;
//PrintFault(IoErr(), "Read");
} /* if */
} /* while */
if (lines && !retval) {
//PrintFault(IoErr(), "Read");
retval = RETURN_WARN;
} /* if */
} else {
//PrintFault(ERROR_BAD_NUMBER, "Read");
SetIoErr(ERROR_BAD_NUMBER);
} /* if */
}};
};
#endif